/*
 * @Description: file content
 * @Author: Zt2tzzt
 * @Date: 2021-09-22 17:18:31
 * @LastEditors: Zt2tzzt
 * @LastEditTime: 2021-09-22 17:23:59
 * @LastEditContent: 
 */
// 工厂模式:工厂函数
function createPerson(name, age, height, address) {
  var p = {}
  p.name = name
  p.age = age
  p.height = height
  p.address = address
  p.eating = function() {
    console.log(this.name, '在吃东西')
  },
  p.running = function() {
    console.log(this.name, '在跑步')
  }
  return p
}

var p1 = createPerson('张三', 18, 1.88, '广州市')
var p2 = createPerson('李四', 20, 1.98, '上海市')
var p3 = createPerson('王五', 30, 1.78, '北京市')

// 工厂模式的缺点 (获取不到对象最真实的类型)
console.log(p1, p2, p3)